<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <script rel="script" src="jquery-3.7.0.js"></script>
    <title>Document</title>
</head>
<body>
<input name="num1" id="num1" type="text" /> + <input name="num2" id="num2" type="text" />
<button id="cal">=</button>
<span id="res"></span>
<script>
    $("#cal").click(function (){
        $.ajax({
            url: "sum",
            dataType: "text",
            data: {
                num1: $("#num1").val(),
                num2: $("#num2").val()
            },
            success: function (sum){
                $("#res").text(sum)
            }
        })
    })
</script>
</body>
</html>